<?php

class Msetting extends CI_Model {
	
	public $table = 'tbl_config';
	public $pri_key="config_id";


	function __construct()

	{

		parent::__construct();
		
	}
	// get category 

	public function get_data()
	{
		return $this->db->get($this->table)->result_array();
	}
	public function get_sub_from_cate($id)
	{
		//$this->db->where("cate_id",$id);
		return $this->db->get($this->table)->result_array();
	}

	public function insert($data){

		if($this->db->insert($this->table,$data))
			return true;
		
		return false;

	}
	public function get_lang()
	{
		$data = $this->db->get($this->table)->row_array();
		if($data['languages'] != '')
		{
			return $data['languages'];
		}
		else
			return false;
	}
		function update($data,$id)
	{
		if(is_numeric($id) && $id !='')
		{
			$this->db->where($this->pri_key,$id);
			
			if($this->db->update($this->table,$data))
				return true;
			return false;
			
		}
		return false;
	}
	public function info_from_id($id)
	{
		if(is_numeric($id) && $id !="")
		{
		$this->db->where($this->pri_key.' =',$id);
		return $this->db->get($this->table)->result_array();
		}
		else
			return false;
	}
		
	public function list_data($num,$off)
	{
		$this->db->limit($off,$num);
		
		$this->db->order_by($this->pri_key,"DESC");
		if($this->db->count_all($this->table) >0)
			//return $this->db->get($this->table)->result_array();
			{
		
	
			return $this->db->get($this->table)->result_array();
			}
		return false;
	}
	// dem so record 
	function count_all()
	{
		return $this->db->count_all_results($this->table);
	}

	function delete()

	{

		if (isset($_POST['select_id']))

		{

			foreach($_POST['select_id'] as $id) {

			//	$row = $this->info_from_id($id);

		

				//xoa file

		//		if ($row['avatar'] != 'null') unlink($row['avatar']);

		

				//xoa CSDL

			//	$sql = "DELETE FROM human_resources WHERE id=$id";
				$this->db->where($this->pri_key, $id);
				$this->db->delete($this->table); 
				//$this->db->query($sql);

			}			

		}

	}

}//end model class





/* End of file mhumans.php */

/* Location: ./system/application/models/mhumans.php */

?>